package com.baidu.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baidu.entity.Shipment;
import com.baidu.entity.dto.ListDTO;
import com.baidu.entity.dto.TestDTO;
import com.baidu.mapper.ShipmentMapper;
import com.baidu.service.IShipmentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mysql.cj.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * @Author Mawq
 * @Date 2021/8/30 17:02
 * @Version 1.0
 */
@Service
public class ShipmentServiceImpl extends ServiceImpl<ShipmentMapper, Shipment> implements IShipmentService {

    @Autowired(required = true)
    private ShipmentMapper shipmentMapper;

    @Override
    public Object getList(TestDTO dto) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if(ObjectUtil.isNotNull(dto.getOrderName())){
          queryWrapper.eq("order_number",dto.getOrderName());
        }
        return shipmentMapper.selectList(queryWrapper);
    }

    @Override
    public IPage<Shipment> getListByPage(ListDTO dto) {
        Page<Shipment> page = new Page<>();
        page.setSize(dto.getPageSize());
        page.setPages(dto.getPageNo());
        return shipmentMapper.getListPage(page,dto.getStatus());
    }
}
